/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pfc.modeloer;

import org.w3c.dom.Element;

/**
 *
 * @author xandru
 */
public class RelationShipFactory {

    static ERRelationShip createRelationShip(Element ele) {
        String tipoStr = ele.getAttribute("type");
        ERRelationShip.RelationType tipo = ERRelationShip.RelationType.valueOf(tipoStr);
        
        ERRelationShip r=null;

        switch(tipo)
        {
            case ManyToMany:
                r = new ManyToManyRelationShip();
                return r;
            case OneToMany:
                r = new OneToManyRelationShip();
                return r;
            case OneToOne:
                r = new OneToOneRelationShip();
                return r;
        }
        /*
        if (tipo.equals(ERRelationShip.RelationType.ManyToMany))
        {
                r = new ManyToManyRelationShip();
                return r;
        }
        if (tipo.equals(ERRelationShip.RelationType.OneToMany))
        {
            r = new OneToManyRelationShip();
            return r;
        }
        if (tipo.equals(ERRelationShip.RelationType.OneToOne))
        {
            r = new OneToOneRelationShip();
            return r;
        }
*/
        return r;
    }
}
